package com.gitee.dolt.weixin.mp.event;


import com.gitee.dolt.weixin.mp.entity.WxMpMsgSendLogDTO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import java.util.function.Consumer;


/**
 * 异步监听短信发送事件
 *
 * @author LYH
 */
@Slf4j
@AllArgsConstructor
public class WxMpMsgSendLogListener {

    private Consumer<WxMpMsgSendLogDTO> consumer;

    @Async
    @Order
    @EventListener(WxMpMsgSendLogEvent.class)
    public void handlerSysLog(WxMpMsgSendLogEvent event) {
        WxMpMsgSendLogDTO smsLog = (WxMpMsgSendLogDTO) event.getSource();
        consumer.accept(smsLog);
    }

}
